from django.conf.urls import patterns, include, url
from django.contrib import admin
from courses.models import Course, Request
from messagingBoard.models import Message
from quiz.models import Lecture,Quiz,Grade,Answer,filename
from django.views.generic.simple import direct_to_template
from django.conf import settings
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

admin.autodiscover()
class AnsweInline(admin.TabularInline):
    model = Answer
    extra = 3

class QuizAdmin(admin.ModelAdmin):
    inlines=[AnsweInline]    
admin.site.register(Quiz,QuizAdmin)
admin.site.register(Course)
admin.site.register(Message)
admin.site.register(Lecture)
admin.site.register(Grade)
admin.site.register(filename)
admin.site.register(Request)




# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
     url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
     url(r'', include('django.contrib.staticfiles.urls')),
     url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT } ),

#admin URLS
     url(r'^admin/', include(admin.site.urls)),

#Messaging URLS
     url(r'^courses/tweet/(?P<course_id>\d+)$', 'quiz.views.writeMessage'),
     url(r'^messages/submit/(?P<lecture_id>\d+)$', 'quiz.views.submitMessage'),
     url(r'^messages/list/(?P<lecture_id>\d+)$', 'quiz.views.listMessages'),
     url(r'^messages/fetch/(?P<lecture_id>\d+)/(?P<length>\d+)$', 'quiz.views.fetch'),
     url(r'^messages/show/(?P<message_id>\d+)$', 'quiz.views.showMessage'),
     url(r'^messages/show1/(?P<message_id>\d+)$', 'quiz.views.showMessage1'),
     url(r'^messages/delete/(?P<msg_id>\d+)$', 'quiz.views.msgdone'),
     

#Teacher Mode

     url(r'^courses/ITeach$', 'courses.views.ITeach'),
     url(r'^courses/ITeach1$', 'courses.views.ITeach1'),
     url(r'^courses/mycourse/(?P<course_id>\d+)$', 'courses.views.t_details'),
     url(r'^courses/create$', 'courses.views.CreateCourse'),
     url(r'^courses/(?P<course_id>\d+)/delete/$', 'courses.views.delcourse'),
     url(r'^courses/deletel/(?P<lecture_id>\d+)$', 'courses.views.deletelecture'),
     url(r'^courses/editname/(?P<course_id>\d+)/$', 'courses.views.changename'),
     url(r'^courses/editinfo/(?P<course_id>\d+)/$', 'courses.views.changeinfo'),
     url(r'^courses/editinfopage/(?P<course_id>\d+)/$', 'courses.views.changeinfopage'),
     url(r'^courses/editlecturename/(?P<lecture_id>\d+)/$', 'courses.views.changelecturename'),
     
     #Requests URLS     
     url(r'^courses/request/(?P<course_id>\d+)/$', 'courses.views.request'),
     url(r'^courses/acceptreq/(?P<request_id>\d+)/$', 'courses.views.acceptreq'),
     url(r'^courses/rejectreq/(?P<request_id>\d+)/$', 'courses.views.rejectreq'),
     url(r'^courses/requests/$', 'courses.views.requests'),
     url(r'^courses/(?P<course_id>\d+)/unsub/$', 'courses.views.unsubscribe'),
    
    
     #Lectures URLS
     url(r'^courses/(?P<course_id>\d+)/lectures/$', 'courses.views.viewLectures'),
     url(r'^quiz/lecture/(?P<lecture_id>\d+)$', 'quiz.views.lectureDetails'),
     url(r'^quiz/lecture/start/(?P<lecture_id>\d+)$', 'quiz.views.startLecture'),
     url(r'^quiz/lecture/end/(?P<lecture_id>\d+)$', 'quiz.views.endLecture'),
     url(r'^quiz/lecture/prepare/(?P<lecture_id>\d+)$', 'quiz.views.prepare'),
     url(r'^courses/(?P<course_id>\d+)/lecture/create$', 'quiz.views.createLecture'),
     
     #Quiz
     url(r'^quiz/(?P<lecture_id>\d+)/create$', 'quiz.views.createQuiz'),
     url(r'^quiz/start/(?P<quiz_id>\d+)$', 'quiz.views.startQuiz'),
     url(r'^quiz/end/(?P<quiz_id>\d+)$', 'quiz.views.endQuiz'),
     url(r'^quiz/take/(?P<course_id>\d+)$', 'quiz.views.takeQuiz'),
     url(r'^quiz/submit/(?P<choice_id>\d+)$', 'quiz.views.submitAnswer'),
     url(r'^quiz/confirm/(?P<answer_id>\d+)$', 'quiz.views.confirm'),
     url(r'^quiz/list/(?P<course_id>\d+)/(?P<user_id>\d+)$', 'quiz.views.listquizes'),
     url(r'^quiz/lecture/getquizzes/(?P<lecture_id>\d+)/$', 'quiz.views.getQuizzes'),     
     
     #Statistics

     url(r'^course/(?P<course_id>\d+)/statistics/(?P<user_id>\d+)$', 'quiz.views.substats'),
     url(r'^quiz/subscribers/(?P<course_id>\d+)$', 'quiz.views.subscribers'),
     url(r'^quiz/(?P<quiz_id>\d+)/get/(?P<user_id>\d+)$', 'quiz.views.getchoice'),
     url(r'^course/(?P<course_id>\d+)/stsubpage/(?P<user_id>\d+)$', 'quiz.views.stsubpage'),
     url(r'^quiz/end1/(?P<quiz_id>\d+)$', 'quiz.views.endQuiz1'),
     url(r'^quiz/stpage/(?P<course_id>\d+)$', 'quiz.views.stpage'),
     url(r'^quiz/allinall/(?P<course_id>\d+)$', 'courses.views.allinall'),
     url(r'^quiz/stclasspage/(?P<course_id>\d+)$', 'courses.views.stclasspage'),
     url(r'^quiz/plectures/(?P<course_id>\d+)$', 'courses.views.listPerviousLectures'),
     url(r'^quiz/plectures/(?P<course_id>\d+)/sub/(?P<user_id>\d+)$', 'courses.views.listsubPerviousLectures'),
     url(r'^quiz/lecture/getpquizzes/(?P<lecture_id>\d+)/$', 'quiz.views.getQuizzes1'),     
     url(r'^quiz/lecture/getpsubquizzes/(?P<lecture_id>\d+)/sub/(?P<user_id>\d+)$', 'quiz.views.getQuizzes2'),     

#Student Mode     
     url(r'^$', 'courses.views.index'),
     url(r'^index1$', 'courses.views.index1'),
     url(r'^courses/(?P<course_id>\d+)/$', 'courses.views.subs_details'),
     url(r'^courses/(?P<course_id>\d+)/confirmun$', 'courses.views.confirmUnsubscribe'),
     
     
     #Subscribe URLS
     url(r'^courses/subscribtionl/(?P<letter>.+)/$', 'courses.views.subscribtionl'),
     url(r'^courses/subscribtion$', 'courses.views.subscribtion'),

#Authentication Section     
     url(r'^accounts/login/$', 'views.login'),
     url(r'^accounts/logout/$', 'views.logout', name='logout'),
     url(r'^accounts/password/change/$', 'views.password_change', name='password_change'),
     url(r'^accounts/password_change/done/$', 'views.password_change_done', name='password_change_done'),
     url(r'^accounts/password_reset/$', 'views.password_reset', name='password_reset'),
     url(r'^accounts/password_reset/done/$', 'views.password_reset_done', name='password_reset_done'),
     url(r'^accounts/reset/(?P<uidb36>[0-9A-Za-z]{1,13})-(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
        'views.password_reset_confirm',
        name='password_reset_confirm'),
     url(r'^accounts/reset/done/$', 'views.password_reset_complete', name='password_reset_complete'),
     
     
     (r'^accounts/', include('registration.urls')),
   
 )
urlpatterns += staticfiles_urlpatterns()
